package com.lqian.array;

import java.util.List;

/**
 * 线程不停的往集合中添加数据
 */
public class ThreadAdd  extends Thread{

    private List list;
//    Lock lock = new ReentrantLock()
    public ThreadAdd(List list) {
        this.list = list;
    }

    @Override
    public void run() {
        for (int i = 0; i <100 ; i++) {
            System.out.println("循环执行->"+ i);
            try {
                Thread.sleep(5);
                list.add(i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
